package com.example.dao;

import com.example.entity.Orderdetail;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;
import java.util.List;

@Mapper
public interface OrderdetailMapper {

    @Select("select * from orderdetail")
    ArrayList<Orderdetail> queryAll();

    @Delete("delete from orderdetail where odId = #{id}")
    int deleteById(Integer id);

    @Select("select * from orderdetail where odID = #{id}")
    Orderdetail findById(Integer id);

    @Select("select * from orderdetail where odid = #{id}")
    Orderdetail findByOid(int id);

    @Update("UPDATE orderdetail SET " +
            "odID = #{orderdetail.oid}," +
            "oID = #{orderdetail.oid}, " +
            "gdID = #{orderdetail.gdid}," +
            "odNum = #{orderdetail.odnum}," +
            "dEvalution = #{orderdetail.devalution}," +
            "odTime = #{orderdetail.odtime}" +
            "WHERE odId = #{orderdetail.odid}")
    int update(@Param("orderdetail") Orderdetail orderdetail);

    @Insert("INSERT INTO orderdetail" +
            "(odID,oID,gdID,odNum,dEvalution,odTime)" +
            "VALUES(#{orderdetail.odid},#{orderdetail.oid},#{orderdetail.gdid},#{orderdetail.odnum},#{orderdetail.devalution},#{orderdetail.odtime})")
    int insert(@Param("orderdetail") Orderdetail orderdetail);

}
